// component/tab/tab.js
Component({
  options: {
    addGlobalClass:true,
    multipleSlots: true, // 允许组件中使用多个slot
    tab:0,
    role:'',
    vehicle_id:''
  },
  /**
   * 组件的属性列表
   */
  properties: {
    tab: String,
    role:String,
    vehicle_id:Number
  },

  /**
   * 组件的初始数据
   */
  data: {
    TabCur: 0,
    scrollLeft: 0
  },
  ready(e) { 
    this.setData({
      TabCur:this.data.tab,
      vehicle_id: this.data.vehicle_id
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    tabSelect(e) {
      var that = this;
      var index = e.currentTarget.dataset.id;
      this.setData({
        TabCur: index,
        scrollLeft: (index - 1) * 60
      })
      //基本信息
      if (index == 0) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_detail?tab=0&id=' + that.data.vehicle_id,
        })
      }
      //运营
      if (index == 1) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_business?tab=1&id=' + that.data.vehicle_id,
        })
      }
      //加油
      if (index == 2) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_gasrecord?tab=2&id=' + that.data.vehicle_id,
        })
      }
      //充电
      if (index == 16) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_recharge?tab=16&id=' + that.data.vehicle_id,
        })
      }
      //高速费，ETC
      if (index == 3) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_tollfee?tab=3&id=' + that.data.vehicle_id,
        })
      }
      //停车费，ETC
      if (index == 24) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_parkingfee?tab=24&id=' + that.data.vehicle_id,
        })
      }
      //保养
      if (index == 4) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_maintenance?tab=4&id=' + that.data.vehicle_id,
        })
      }
      //轮胎
      if (index == 5) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_tire?tab=5&id=' + that.data.vehicle_id,
        })
      }
       //维修
       if (index == 6) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_repair?tab=6&id=' + that.data.vehicle_id,
        })
      }
      //事故
      if (index == 7) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_accident?tab=7&id=' + that.data.vehicle_id,
        })
      }
      //尿素
      if (index == 8) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_adblue?tab=8&id=' + that.data.vehicle_id,
        })
      }
      //保洁
      if (index == 9) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_clean?tab=9&id=' + that.data.vehicle_id,
        })
      }
      //违章
      if (index == 10) {
       wx.redirectTo({
         url: '/pages/vehicle/vehicle_traffic_offence?tab=10&id=' + that.data.vehicle_id,
       })
     }
      //年审
      if (index == 11) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_annual_review?tab=11&id=' + that.data.vehicle_id,
        })
      }
      //保险
      if (index == 12) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_insurance?tab=12&id=' + that.data.vehicle_id,
        })
      }
      //出车检查
      if (index == 13) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_check?tab=13&id=' + that.data.vehicle_id,
        })
      }
      //月供
      if (index == 14) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_monthly_loan?tab=14&id=' + that.data.vehicle_id,
        })
      }
      //车载物联设备
      if (index == 15) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_iot?tab=15&id=' + that.data.vehicle_id,
        })
      }
      //油卡
      if (index == 21) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_oil_card?tab=21&id=' + that.data.vehicle_id,
        })
      }
      //冷机
      if (index == 22) {
        wx.redirectTo({
          url: '/pages/vehicle/vehicle_cold_machine?tab=22&id=' + that.data.vehicle_id,
        })
      }
    }
    
  }
})
